﻿using System.Runtime.Serialization;
using System.Xml.Linq;
using System.Linq;

namespace BaseTypesLib.Model
{
    /// <summary>
    /// This is the base class for all screens (popup, main screens, etc)
    /// </summary>

    public abstract class Screen:Manager
    {
        private bool defClose, defMenu;

        public bool DefaultClose
        {
            get { return defClose; }
            set
            {
                if (defClose != value)
                {
                    defClose = value;
                    OnPropertyChanged("DefaultClose");
                }
            }
        }

        public bool DefaultMenu
        {
            get { return defMenu; }
            set
            {
                if (defMenu != value)
                {
                    defMenu = value;
                    OnPropertyChanged("DefaultMenu");
                }
            }
        }
        public override ManagerLayout ManagerLayout
        {
            get { return ManagerLayout.Vertical; }
        }
        protected override XElement GetXmlElement()
        {
            XElement el = base.GetXmlElement();
            el.SetAttributeValue("DefaultMenu", DefaultMenu);
            el.SetAttributeValue("DefaultClose", DefaultClose);

            return el;
        }
        protected override void FromXmlElement(XElement elem)
        {
            base.FromXmlElement(elem);
            var dc = elem.Attributes("DefaultClose").FirstOrDefault();
            if (dc != null) DefaultClose = (bool)dc;

            var dm = elem.Attributes("DefaultMenu").FirstOrDefault();
            if (dm != null) DefaultMenu = (bool)dm;
        }
    }
}
